﻿<%@ Page Title="" Language="C#" MasterPageFile="~/temp/main/main.Master" AutoEventWireup="true" CodeBehind="confirm.aspx.cs" Inherits="Donal.Xms.Web.temp.main.confirm" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script>
        $(function () {

        })

        function SubmitOrder(delivery) {
            let remark = $("#txtRemark").val();
            let address = $("#selectAddress").val();
            let $submitButton = $('input[type="button"]');
            // 禁用提交按钮
            $submitButton.prop('disabled', true);

            let wait = dialog({
                title: "请稍后……"
            }).showModal();

            $.post("/tools/submit_ajax.ashx?action=submitOrder_" + new Date().getTime(), { delivery, address, remark }, function (ref) {
                // 启用提交按钮
                $submitButton.prop('disabled', false);
                wait.close();

                switch (ref.status) {
                    case 1:
                        if (delivery <= 2) {
                            window.location.href = "/payment/" + ref.msg + ".html";
                        } else {
                            window.location.href = "/user/orders/all.html";
                        }
                        break;
                    case 2:
                        showDialog(ref.msg);
                        window.location.reload();
                        break;
                }                            

            }, 'json');
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div>
        <asp:Repeater ID="rptCategory" runat="server" OnItemDataBound="rptCategory_ItemDataBound">
            <HeaderTemplate>
                <div>
                    <table style="width: 100%">
                        <tr>
                            <th style="width: 5%">序号</th>
                            <th style="width: 20%">规格名称</th>
                            <th style="width: 10%">产品名称</th>
                            <th style="width: 10%">产品类别</th>
                            <th style="width: 10%">含税单价</th>
                            <th style="width: 10%">订购数量</th>
                            <th style="width: 10%">小计</th>
                        </tr>
            </HeaderTemplate>
            <ItemTemplate>

                <asp:HiddenField ID="hidId" runat="server" Value='<%#Eval("id") %>' />

                <asp:Repeater ID="rptList" runat="server">
                    <ItemTemplate>
                        <tr id="tr_<%# Eval("id") %>">
                            <td style="text-align: center;">
                                <%# Eval("index") %>
                            </td>
                            <td style="text-align: center;">
                                <%# Eval("title") %>
                                <p>
                                    <%# Eval("fields") %>
                                </p>
                            </td>
                            <td style="text-align: center;"><%# Eval("product_title") %></td>
                            <td style="text-align: center;"><%# Eval("category_title") %></td>
                            <td style="text-align: center;">￥<%# Eval("discount_price") %></td>
                            <td style="text-align: center;"><%# Eval("quantity") %></td>
                            <td style="text-align: center;">￥<%# Eval("amount") %></td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                <tr>
                    <td colspan="7" style="border-bottom: 1px solid #808080"></td>
                </tr>

            </ItemTemplate>
            <FooterTemplate>
                </table>
                </div>
            </FooterTemplate>
        </asp:Repeater>
        <br />
        <label>应付金额：￥<%=_amount %></label>
        <br />
        <br />

        <select id="selectAddress">
            <option value="0" <% = rptAddress.Items.Count==0?"selected=\"selected\"":"" %>>自提</option>
            <asp:Repeater ID="rptAddress" runat="server">
                <ItemTemplate>
                    <option <%# Eval("is_default").ToString()=="1"?"selected=\"selected\"":"" %> value="<%# Eval("id") %>"><%# Eval("accept_name")+" "+ Eval("mobile")+" "+ Eval("area")+" "+ Eval("address")%></option>
                </ItemTemplate>
            </asp:Repeater>
        </select>
        <br />
        <br />
        <textarea id="txtRemark"></textarea>
        <br />
        <br />
        <input type="button" onclick="SubmitOrder(1)" value="提交订单" />
        <input type="button" onclick="SubmitOrder(2)" value="提交分批发货订单" />
        <input type="button" onclick="SubmitOrder(3)" value="加入订单库" />
    </div>
</asp:Content>
